package com.woniuxy.micromemberserver.mapper;

import com.woniuxy.micromemberserver.bean.MemberTypeBean;
import com.woniuxy.micromemberserver.bean.PageRequest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 会员类型持久层
 * @Author hz
 */
@Mapper
public interface MemberTypeMapper {

    /**
     * 条件分页查询
     * @param request 分页请求
     * @param memberTypeBean 会员类型实体
     * @return
     */
    List<MemberTypeBean> findAllByParams(@Param("p") PageRequest request, @Param("m") MemberTypeBean memberTypeBean);

    /**
     * 新增会员类型
     * @param memberTypeBean
     * @return
     */
    @Options(
        useGeneratedKeys = true,
        keyProperty = "m.id"
    )
    @Insert(
        "insert into t_member_type_info "+
        "(member_code, level_name, exp, sale_status, integral_multiple) values"+
        "(#{m.memberCode}, #{m.levelName}, #{m.exp}, #{m.saleStatus}, #{m.integralMultiple})"
    )
    int saveMemberType(@Param("m") MemberTypeBean memberTypeBean);

    /**
     * 修改会员类型（或删除：仅修改删除标记）
     * @param memberTypeBean
     * @return
     */
    int updateMemberType(@Param("m") MemberTypeBean memberTypeBean);
}
